<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
</head>

<body>
    <div id="root"></div>
</body>
<script type="text/babel">
    // const root = ReactDOM.createRoot(document.querySelector("#root"));
    // root.render((
    //     <div></div>
    // ))

    const root = document.querySelector('#root');
    class Header extends React.Component {
        render() {
            return <div>header</div>
        }
    }
    function render(reactCom, root) {
        console.log('reactCom: ',reactCom); // type属性中装的就是类组件的构造函数
        // 1. 实例化该类组件
        const instance = new reactCom.type();
        // 获取组件的vdom，也就是return返回的jsx
        const vdom = instance.render();
        console.log('vdom: ', vdom);
        // 创建真实dom
        const realDom = document.createElement(vdom.type)
        realDom.innerHTML = vdom.props.children;
        root.appendChild(realDom);
    }

    render(<Header/>, root);
</script>

</html>